-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
haskell.compiler.ghc*: cross-compiled ghc [iteration on alex's PR] #305392
haskell.compiler.ghc*: cross-compiled ghc [iteration on alex's PR] #305392
Conversation
I like the change to use ghc-settings-edit, but would you mind adding a comment inside the LHS file and/or the meta description to briefly explain what the script is used for? As mentioned in this comment of the original PR, the settings file apparently still references the build platform's LLVM. I'll test |
Yes, I'll do that.
Forgot about that, I'll look into that. This is basically the case the old asserts guarded against?
|
I think so. |
The GHC 9.4.8 cross-build still needs to be unregisterised, but through the rebuild I was able to obtain a fully functional native RISC-V compiler, so there has been no regression on that front. Since a cross-compiled 9.4.8 can be used to boot a native 9.6.5, please feel free to update the cross sanity test to build 9.4.8 instead of 8.10.7. |
This error is probably what led me to believe that only 8.10 and 9.0 were usable as boot compilers:
At the time, Nixpkgs had not yet switched to 9.6. |
da72955
to
c5f0619
Compare
Added some commentary to the ghc-settings-edit.lhs file. |
c5f0619
to
cb0e5d0
Compare
1e7476f
to
39fbcaf
Compare
Follow-up PRs:
|
fedb5a4
to
75cab63
Compare
ca53372
to
3ff0c66
Compare
@AlexandreTunstall Does |
f8dfa10
to
15afc8b
Compare
Successfully compile. |
GHC's build system assumes that the C compiler, tools etc. discovered during configure can also be used at runtime. This means that the CC, LD, AR etc. variables given at runtime are used to populate the settings file which GHC uses to lookup the tools it needs. The implicit assumption of this mechanism is that the build and runtime environment of GHC are similar enough and PATH is used to find the tools. I. e. if we set CC=clang, we wouldn't need to worry about this as much. We, however, pass absolute paths which is useful since it allows GHC to work outside of stdenv (as long as e. g. no FFI is involved). Even so, until now, we didn't really have any problems stemming from this, as we used pkgsBuildTarget to get everything we need. The compiler we'd want to execute would in principle need to come from pkgsHostTarget. 1. For native compilers, all package sets are the same since build == host == target. 2. For cross compilers build == host, so pkgsBuildTarget is practically the same as pkgsHostTarget. When cross-compiling a native compiler, build != host, so we need to actually ensure that GHC uses different tools at runtime compared to bootstrapping. There is currently no intended way to achieve this, so we use a custom tool to edit the settings file. An alternative would be to patch the build system, but this would be difficult to maintain. We could go down this route if there's interest from upstream to provide a proper way to specify the runtime tools. Co-authored-by: sternenseemann <[email protected]>
15afc8b
to
9e3f639
Compare
|
It's been a while since I wrote that change, so I can't remember. |
pkgs/test/cross/default.nix
Outdated
@@ -146,6 +146,8 @@ let | |||
pkgs.pkgsCross.mips64el-linux-gnuabi64.stdenv | |||
pkgs.pkgsCross.mips64el-linux-gnuabin32.stdenv | |||
pkgs.pkgsCross.mingwW64.stdenv | |||
# Unlike later versions, cross-compiled 8.10.7 can reliably bootstrap a native build | |||
pkgs.pkgsCross.riscv64.haskell.compiler.integer-simple.ghc8107 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we update this to 9.4.8 now that we know it works on aarch64 and riscv64?
(I originally used 8.10.7 because an unrelated problem prevented me from bootstrapping with a newer compiler.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe an idea, I think we can expand the test list a bit (in release-haskell.nix), but should keep it to the essential stuff in the test.
The nice thing about 8.10.7 is of course that it can be used to start a bootstrap chain of all compilers in nixpkgs.
Also, we should be able to use gmp now if gmp can be cross compiled to riscv64.
On the latest version of this PR, |
9e3f639
to
6957b21
Compare
I've confirmed that it only influences the manual build which isn't problematic when cross-compiling GHC. We only need/should disable it if it is a hassle to build sphinx for the host platform (e.g. as is the case with musl). |
Propagating the supported platforms of the boot compiler doesn't make much sense when unregistered cross-compilation is possible.
This is to ensure that Haskell users on platforms that lack official bindists still have a convenient means of getting GHC running natively. In my admittedly somewhat limited testing on RISC-V, GHC 8.10.7 is able to bootstrap native builds for 9.2.8 and 9.4.5. GHC 9.2.8 and 9.4.5 are unable to bootstrap themselves and 9.6.2 when cross-compiled. If you're looking at this commit to see whether you can safely upgrade the compiler used here to remove 8.10, please try cross-compiling 9.0 or later and then booting a native GHC with it.
Hadrian started installing unlit with a targetPrefix (if applicable) which wasn't the case with make before. Unfortunately, the logic to generate the settings file wasn't updated, so GHC 9.6.* cross compilers expect to find an unlit binary without a target prefix. Upstream issue: https://gitlab.haskell.org/ghc/ghc/-/issues/23317
The build platform doesn't matter for checking which stage is our final stage! Stage2 means host and target are sufficiently similar, Stage1 means host and target may differ.
Note that the clang command should be adapted in the future as done for CLANG in NixOS#338782.
6957b21
to
df16902
Compare
Description of changes
Based on #243619
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.